package com.study.flie;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class FileTest {
    public static void main(String[] args) {
        //获取读取流
        FileReader reader = null;
        try {
            reader = new FileReader("E:\\12(1).txt");
            BufferedReader br = new BufferedReader(reader);
            StringBuilder sb=new StringBuilder();
            String line = br.readLine();
            while (line!= null) {
                sb.append(line);
                line = br.readLine();
                //注意这里输出的是readLine()，while循环中的和输出中的readLine()方法被掉了两次，所以会隔行读取。
            }
            System.out.println(sb);

            //关闭读取流
            br.close();
            reader.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
